package com.yue.rabbitmq.controller;

import com.yue.rabbitmq.service.impl.RabbitMQProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private RabbitMQProducer rabbitMQProducer;

    /**
     * http://localhost:8080/test/send?exchange=l4&routeKey=4g01&msg=hello
     * @param exchange
     * @param routeKey
     * @param msg
     * @return
     */
    @RequestMapping("/send")
    public String sendTopic(@RequestParam String exchange, @RequestParam String routeKey,@RequestParam String msg) {
        rabbitMQProducer.sendMsg(exchange,routeKey,msg);
      return String.format("exchange:%s,routeKey:%s,msg:%s",exchange,routeKey,msg);
    }

}
